#include "cmdbuf.h"

namespace cyb
{

uint64_t SortKey::Encode() const
{
	const uint64_t depth   = m_depth;
	const uint64_t program = uint64_t( m_program )     << 0x18;
	const uint64_t trans   = uint64_t( m_translucecy ) << 0x34;
	const uint64_t layer   = uint64_t( m_layer )       << 0x36;
	const uint64_t view    = uint64_t( m_viewport )    << 0x3b;
	const uint64_t key     = depth | program | trans | layer | view;
	return key;
}

void SortKey::Decode( const uint64_t key )
{
	m_depth       =  key & 0xffffff;
	m_program     = ( key >> 0x18 ) & 0xfffffff;
	m_translucecy = ( key >> 0x34 ) & 0x3;
	m_layer       = ( key >> 0x36 ) & 0x1f;
	m_viewport    = ( key >> 0x3b ) & 0x1f;
}

}	// namespace cyb